﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Chinesys.Entities;

namespace Chinesys.Domain.InputValidations
{
    public class UserAppInRoleInputValidation : InputValidationBase
    {
        private UserAppInRoleEntity userRole;

        public UserAppInRoleInputValidation(UserAppInRoleEntity userRole)
        {
            this.userRole = userRole;
        }

        public override void Validate()
        {
            if (userRole.RoleId == 0)
                Errors.Add(new Required("Role Id"));

            if (userRole.UserAppId == 0)
                Errors.Add(new Required("User Id"));

            if (!string.IsNullOrEmpty(userRole.Description) && userRole.Description.Length > 500)
            {
                Errors.Add(new Lenght("Description", 500));
            }
        }
    }
}
